#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
exec tclsh "$0" ${1+"$@"}

# Test fix for issue 66:
#
# "s/.../\u&/" which should change the case of the first character of
# the replacement text (not all of it).
# If the replacement test character results in no characters, it should
# change the case of the following character.
#
# Was https://github.com/martinwguy/xvi/issues/66

source scripts/term
start_vi

# Check it started up OK
test 100 ""					1 0 [list "" "~"]

test 101 "aThe cat sat on the mat.[esc]"	1 22 "{The cat sat on the mat.}"

# Run the POSIX tests
# Remember to quote \, [ and $ to get ":s/\<.at\>/\u&/g"
test 102 ":s/\\<.at\\>/\\u&/g\r"   1 0 "{The Cat Sat on the Mat.}"

;# :s/S\(.*\)M/S\U\1\eM/
test 103 ":s/S\\(.*\\)M/S\\U\\1\\eM/\r"		1 0 "{The Cat SAT ON THE Mat.}"

# Check that \u or \l followed by an empty replacement string carries over
# to the first char of the following text.
;# :s/ \(x*\)/\l\1E/
test 104 ":s/ \\(x*\\)/ \\l\\1E/\r"		1 0 "{The eCat SAT ON THE Mat.}"

stop_vi

exit 0
